USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[View_BDSP-Insert]    Script Date: [[20120714223945]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223945]]
-- Description:	Insert record into table [dbo].[View_BDSP]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[View_BDSP-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[View_BDSP-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[View_BDSP-Insert]
	/*@Bill_RowNumber int =Null  , 
	@Bill_ID uniqueidentifier =Null  , 
	@Bill_Code varchar(50) =Null  , 
	@BillType_ID uniqueidentifier =Null  , 
	@BillType_Code varchar(50) =Null  , 
	@BillType_NameAr varchar(300) =Null  , 
	@BillType_NameEn varchar(300) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerTypeCode varchar(50) =Null  , 
	@DealerType_NameAr varchar(300) =Null  , 
	@DealerType_NameEn varchar(300) =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Dealer_Code varchar(50) =Null  , 
	@Dealer_NameAr varchar(300) =Null  , 
	@Dealer_NameEn varchar(300) =Null  , 
	@BillDetail_ID uniqueidentifier =Null  , 
	@Product_ID uniqueidentifier =Null  , 
	@Product_Code varchar(50) =Null  , 
	@Product_NameAr varchar(300) =Null  , 
	@Product_NameEn varchar(300) =Null  , 
	@Quantity float =Null  , 
	@Price float =Null  , 
	@MeasureUnit_ID uniqueidentifier =Null  , 
	@MeasureUnit_Code varchar(50) =Null  , 
	@MeasureUnit_NameAr varchar(300) =Null  , 
	@MeasureUnit_NameEn varchar(300) =Null  , 
	@Offer_ID uniqueidentifier =Null  , 
	@Offer_Notes varchar(max) =Null  , 
	@Store_ID uniqueidentifier =Null  , 
	@Store_Code varchar(50) =Null  , 
	@Store_NameAr varchar(300) =Null  , 
	@Store_NameEn varchar(300) =Null  , 
	@Store_Address varchar(500) =Null  , 
	@IsSellPlace tinyint =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[View_BDSP](/*[Bill_RowNumber], [Bill_ID], [Bill_Code], [BillType_ID], [BillType_Code], [BillType_NameAr], [BillType_NameEn], [DealerType_ID], [DealerTypeCode], [DealerType_NameAr], [DealerType_NameEn], [Dealer_ID], [Dealer_Code], [Dealer_NameAr], [Dealer_NameEn], [BillDetail_ID], [Product_ID], [Product_Code], [Product_NameAr], [Product_NameEn], [Quantity], [Price], [MeasureUnit_ID], [MeasureUnit_Code], [MeasureUnit_NameAr], [MeasureUnit_NameEn], [Offer_ID], [Offer_Notes], [Store_ID], [Store_Code], [Store_NameAr], [Store_NameEn], [Store_Address], [IsSellPlace]*/)
	VALUES     (/*@Bill_RowNumber, @Bill_ID, @Bill_Code, @BillType_ID, @BillType_Code, @BillType_NameAr, @BillType_NameEn, @DealerType_ID, @DealerTypeCode, @DealerType_NameAr, @DealerType_NameEn, @Dealer_ID, @Dealer_Code, @Dealer_NameAr, @Dealer_NameEn, @BillDetail_ID, @Product_ID, @Product_Code, @Product_NameAr, @Product_NameEn, @Quantity, @Price, @MeasureUnit_ID, @MeasureUnit_Code, @MeasureUnit_NameAr, @MeasureUnit_NameEn, @Offer_ID, @Offer_Notes, @Store_ID, @Store_Code, @Store_NameAr, @Store_NameEn, @Store_Address, @IsSellPlace*/)

	/**/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[View_BDSP-update]    Script Date: [[20120714223945]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223945]]
-- Description:	Update record in table [dbo].[View_BDSP]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[View_BDSP-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[View_BDSP-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[View_BDSP-update]
	/*@Bill_RowNumber int =Null  , 
	@Bill_ID uniqueidentifier =Null  , 
	@Bill_Code varchar(50) =Null  , 
	@BillType_ID uniqueidentifier =Null  , 
	@BillType_Code varchar(50) =Null  , 
	@BillType_NameAr varchar(300) =Null  , 
	@BillType_NameEn varchar(300) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerTypeCode varchar(50) =Null  , 
	@DealerType_NameAr varchar(300) =Null  , 
	@DealerType_NameEn varchar(300) =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Dealer_Code varchar(50) =Null  , 
	@Dealer_NameAr varchar(300) =Null  , 
	@Dealer_NameEn varchar(300) =Null  , 
	@BillDetail_ID uniqueidentifier =Null  , 
	@Product_ID uniqueidentifier =Null  , 
	@Product_Code varchar(50) =Null  , 
	@Product_NameAr varchar(300) =Null  , 
	@Product_NameEn varchar(300) =Null  , 
	@Quantity float =Null  , 
	@Price float =Null  , 
	@MeasureUnit_ID uniqueidentifier =Null  , 
	@MeasureUnit_Code varchar(50) =Null  , 
	@MeasureUnit_NameAr varchar(300) =Null  , 
	@MeasureUnit_NameEn varchar(300) =Null  , 
	@Offer_ID uniqueidentifier =Null  , 
	@Offer_Notes varchar(max) =Null  , 
	@Store_ID uniqueidentifier =Null  , 
	@Store_Code varchar(50) =Null  , 
	@Store_NameAr varchar(300) =Null  , 
	@Store_NameEn varchar(300) =Null  , 
	@Store_Address varchar(500) =Null  , 
	@IsSellPlace tinyint =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/**/
		Update [dbo].[View_BDSP] SET 
		/*[Bill_RowNumber] =@Bill_RowNumber, 
		[Bill_ID] =@Bill_ID, 
		[Bill_Code] =@Bill_Code, 
		[BillType_ID] =@BillType_ID, 
		[BillType_Code] =@BillType_Code, 
		[BillType_NameAr] =@BillType_NameAr, 
		[BillType_NameEn] =@BillType_NameEn, 
		[DealerType_ID] =@DealerType_ID, 
		[DealerTypeCode] =@DealerTypeCode, 
		[DealerType_NameAr] =@DealerType_NameAr, 
		[DealerType_NameEn] =@DealerType_NameEn, 
		[Dealer_ID] =@Dealer_ID, 
		[Dealer_Code] =@Dealer_Code, 
		[Dealer_NameAr] =@Dealer_NameAr, 
		[Dealer_NameEn] =@Dealer_NameEn, 
		[BillDetail_ID] =@BillDetail_ID, 
		[Product_ID] =@Product_ID, 
		[Product_Code] =@Product_Code, 
		[Product_NameAr] =@Product_NameAr, 
		[Product_NameEn] =@Product_NameEn, 
		[Quantity] =@Quantity, 
		[Price] =@Price, 
		[MeasureUnit_ID] =@MeasureUnit_ID, 
		[MeasureUnit_Code] =@MeasureUnit_Code, 
		[MeasureUnit_NameAr] =@MeasureUnit_NameAr, 
		[MeasureUnit_NameEn] =@MeasureUnit_NameEn, 
		[Offer_ID] =@Offer_ID, 
		[Offer_Notes] =@Offer_Notes, 
		[Store_ID] =@Store_ID, 
		[Store_Code] =@Store_Code, 
		[Store_NameAr] =@Store_NameAr, 
		[Store_NameEn] =@Store_NameEn, 
		[Store_Address] =@Store_Address, 
		[IsSellPlace] =@IsSellPlace*/
		/**/
	/**/

	/**/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[View_BDSP-Insert-Update]    Script Date: [[20120714223945]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223945]]
-- Description:	Insert OR Update record into table [dbo].[View_BDSP]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[View_BDSP-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[View_BDSP-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[View_BDSP-Insert-Update]
	/*@Bill_RowNumber int =Null  , 
	@Bill_ID uniqueidentifier =Null  , 
	@Bill_Code varchar(50) =Null  , 
	@BillType_ID uniqueidentifier =Null  , 
	@BillType_Code varchar(50) =Null  , 
	@BillType_NameAr varchar(300) =Null  , 
	@BillType_NameEn varchar(300) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerTypeCode varchar(50) =Null  , 
	@DealerType_NameAr varchar(300) =Null  , 
	@DealerType_NameEn varchar(300) =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Dealer_Code varchar(50) =Null  , 
	@Dealer_NameAr varchar(300) =Null  , 
	@Dealer_NameEn varchar(300) =Null  , 
	@BillDetail_ID uniqueidentifier =Null  , 
	@Product_ID uniqueidentifier =Null  , 
	@Product_Code varchar(50) =Null  , 
	@Product_NameAr varchar(300) =Null  , 
	@Product_NameEn varchar(300) =Null  , 
	@Quantity float =Null  , 
	@Price float =Null  , 
	@MeasureUnit_ID uniqueidentifier =Null  , 
	@MeasureUnit_Code varchar(50) =Null  , 
	@MeasureUnit_NameAr varchar(300) =Null  , 
	@MeasureUnit_NameEn varchar(300) =Null  , 
	@Offer_ID uniqueidentifier =Null  , 
	@Offer_Notes varchar(max) =Null  , 
	@Store_ID uniqueidentifier =Null  , 
	@Store_Code varchar(50) =Null  , 
	@Store_NameAr varchar(300) =Null  , 
	@Store_NameEn varchar(300) =Null  , 
	@Store_Address varchar(500) =Null  , 
	@IsSellPlace tinyint =Null  , 
	@Inserted bit OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[View_BDSP] 
					/**/)
	BEGIN
		
		INSERT  INTO [dbo].[View_BDSP](/*[Bill_RowNumber], [Bill_ID], [Bill_Code], [BillType_ID], [BillType_Code], [BillType_NameAr], [BillType_NameEn], [DealerType_ID], [DealerTypeCode], [DealerType_NameAr], [DealerType_NameEn], [Dealer_ID], [Dealer_Code], [Dealer_NameAr], [Dealer_NameEn], [BillDetail_ID], [Product_ID], [Product_Code], [Product_NameAr], [Product_NameEn], [Quantity], [Price], [MeasureUnit_ID], [MeasureUnit_Code], [MeasureUnit_NameAr], [MeasureUnit_NameEn], [Offer_ID], [Offer_Notes], [Store_ID], [Store_Code], [Store_NameAr], [Store_NameEn], [Store_Address], [IsSellPlace]*/)
		VALUES     (/*@Bill_RowNumber, @Bill_ID, @Bill_Code, @BillType_ID, @BillType_Code, @BillType_NameAr, @BillType_NameEn, @DealerType_ID, @DealerTypeCode, @DealerType_NameAr, @DealerType_NameEn, @Dealer_ID, @Dealer_Code, @Dealer_NameAr, @Dealer_NameEn, @BillDetail_ID, @Product_ID, @Product_Code, @Product_NameAr, @Product_NameEn, @Quantity, @Price, @MeasureUnit_ID, @MeasureUnit_Code, @MeasureUnit_NameAr, @MeasureUnit_NameEn, @Offer_ID, @Offer_Notes, @Store_ID, @Store_Code, @Store_NameAr, @Store_NameEn, @Store_Address, @IsSellPlace*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/**/
			Update [dbo].[View_BDSP] SET 
			/*[Bill_RowNumber] =@Bill_RowNumber, 
			[Bill_ID] =@Bill_ID, 
			[Bill_Code] =@Bill_Code, 
			[BillType_ID] =@BillType_ID, 
			[BillType_Code] =@BillType_Code, 
			[BillType_NameAr] =@BillType_NameAr, 
			[BillType_NameEn] =@BillType_NameEn, 
			[DealerType_ID] =@DealerType_ID, 
			[DealerTypeCode] =@DealerTypeCode, 
			[DealerType_NameAr] =@DealerType_NameAr, 
			[DealerType_NameEn] =@DealerType_NameEn, 
			[Dealer_ID] =@Dealer_ID, 
			[Dealer_Code] =@Dealer_Code, 
			[Dealer_NameAr] =@Dealer_NameAr, 
			[Dealer_NameEn] =@Dealer_NameEn, 
			[BillDetail_ID] =@BillDetail_ID, 
			[Product_ID] =@Product_ID, 
			[Product_Code] =@Product_Code, 
			[Product_NameAr] =@Product_NameAr, 
			[Product_NameEn] =@Product_NameEn, 
			[Quantity] =@Quantity, 
			[Price] =@Price, 
			[MeasureUnit_ID] =@MeasureUnit_ID, 
			[MeasureUnit_Code] =@MeasureUnit_Code, 
			[MeasureUnit_NameAr] =@MeasureUnit_NameAr, 
			[MeasureUnit_NameEn] =@MeasureUnit_NameEn, 
			[Offer_ID] =@Offer_ID, 
			[Offer_Notes] =@Offer_Notes, 
			[Store_ID] =@Store_ID, 
			[Store_Code] =@Store_Code, 
			[Store_NameAr] =@Store_NameAr, 
			[Store_NameEn] =@Store_NameEn, 
			[Store_Address] =@Store_Address, 
			[IsSellPlace] =@IsSellPlace*/
			/**/
		/**/
		
		SET /*@*/Inserted=0
	END

	/**/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[View_BDSP-Delete]    Script Date: [[20120714223945]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223945]]
-- Description:	delete records from table [dbo].[View_BDSP] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[View_BDSP-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[View_BDSP-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[View_BDSP-Delete]
	/*@Bill_RowNumber int =null  , 
	@Bill_ID uniqueidentifier =null  , 
	@Bill_Code varchar(50) =null  , 
	@BillType_ID uniqueidentifier =null  , 
	@BillType_Code varchar(50) =null  , 
	@BillType_NameAr varchar(300) =null  , 
	@BillType_NameEn varchar(300) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerTypeCode varchar(50) =null  , 
	@DealerType_NameAr varchar(300) =null  , 
	@DealerType_NameEn varchar(300) =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Dealer_Code varchar(50) =null  , 
	@Dealer_NameAr varchar(300) =null  , 
	@Dealer_NameEn varchar(300) =null  , 
	@BillDetail_ID uniqueidentifier =null  , 
	@Product_ID uniqueidentifier =null  , 
	@Product_Code varchar(50) =null  , 
	@Product_NameAr varchar(300) =null  , 
	@Product_NameEn varchar(300) =null  , 
	@Quantity float =null  , 
	@Price float =null  , 
	@MeasureUnit_ID uniqueidentifier =null  , 
	@MeasureUnit_Code varchar(50) =null  , 
	@MeasureUnit_NameAr varchar(300) =null  , 
	@MeasureUnit_NameEn varchar(300) =null  , 
	@Offer_ID uniqueidentifier =null  , 
	@Offer_Notes varchar(max) =null  , 
	@Store_ID uniqueidentifier =null  , 
	@Store_Code varchar(50) =null  , 
	@Store_NameAr varchar(300) =null  , 
	@Store_NameEn varchar(300) =null  , 
	@Store_Address varchar(500) =null  , 
	@IsSellPlace tinyint =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[View_BDSP]
	WHERE /*( [Bill_RowNumber] = ISNULL(@Bill_RowNumber, [Bill_RowNumber]) )
	AND ( [Bill_ID] = ISNULL(@Bill_ID, [Bill_ID]) )
	AND ( [Bill_Code] like ISNULL(@Bill_Code, [Bill_Code]) )
	AND ( [BillType_ID] = ISNULL(@BillType_ID, [BillType_ID]) )
	AND ( [BillType_Code] like ISNULL(@BillType_Code, [BillType_Code]) )
	AND ( [BillType_NameAr] like ISNULL(@BillType_NameAr, [BillType_NameAr]) )
	AND ( [BillType_NameEn] like ISNULL(@BillType_NameEn, [BillType_NameEn]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerTypeCode] like ISNULL(@DealerTypeCode, [DealerTypeCode]) )
	AND ( [DealerType_NameAr] like ISNULL(@DealerType_NameAr, [DealerType_NameAr]) )
	AND ( [DealerType_NameEn] like ISNULL(@DealerType_NameEn, [DealerType_NameEn]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Dealer_Code] like ISNULL(@Dealer_Code, [Dealer_Code]) )
	AND ( [Dealer_NameAr] like ISNULL(@Dealer_NameAr, [Dealer_NameAr]) )
	AND ( [Dealer_NameEn] like ISNULL(@Dealer_NameEn, [Dealer_NameEn]) )
	AND ( [BillDetail_ID] = ISNULL(@BillDetail_ID, [BillDetail_ID]) )
	AND ( [Product_ID] = ISNULL(@Product_ID, [Product_ID]) )
	AND ( [Product_Code] like ISNULL(@Product_Code, [Product_Code]) )
	AND ( [Product_NameAr] like ISNULL(@Product_NameAr, [Product_NameAr]) )
	AND ( [Product_NameEn] like ISNULL(@Product_NameEn, [Product_NameEn]) )
	AND ( [Quantity] = ISNULL(@Quantity, [Quantity]) )
	AND ( [Price] = ISNULL(@Price, [Price]) )
	AND ( [MeasureUnit_ID] = ISNULL(@MeasureUnit_ID, [MeasureUnit_ID]) )
	AND ( [MeasureUnit_Code] like ISNULL(@MeasureUnit_Code, [MeasureUnit_Code]) )
	AND ( [MeasureUnit_NameAr] like ISNULL(@MeasureUnit_NameAr, [MeasureUnit_NameAr]) )
	AND ( [MeasureUnit_NameEn] like ISNULL(@MeasureUnit_NameEn, [MeasureUnit_NameEn]) )
	AND ( [Offer_ID] = ISNULL(@Offer_ID, [Offer_ID]) )
	AND ( [Offer_Notes] like ISNULL(@Offer_Notes, [Offer_Notes]) )
	AND ( [Store_ID] = ISNULL(@Store_ID, [Store_ID]) )
	AND ( [Store_Code] like ISNULL(@Store_Code, [Store_Code]) )
	AND ( [Store_NameAr] like ISNULL(@Store_NameAr, [Store_NameAr]) )
	AND ( [Store_NameEn] like ISNULL(@Store_NameEn, [Store_NameEn]) )
	AND ( [Store_Address] like ISNULL(@Store_Address, [Store_Address]) )
	AND ( [IsSellPlace] = ISNULL(@IsSellPlace, [IsSellPlace]) )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[View_BDSP-Select]    Script Date: [[20120714223945]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223945]]
-- Description:	select records from table [dbo].[View_BDSP] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[View_BDSP-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[View_BDSP-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[View_BDSP-Select]
	/*@Bill_RowNumber int =null  , 
	@Bill_ID uniqueidentifier =null  , 
	@Bill_Code varchar(50) =null  , 
	@BillType_ID uniqueidentifier =null  , 
	@BillType_Code varchar(50) =null  , 
	@BillType_NameAr varchar(300) =null  , 
	@BillType_NameEn varchar(300) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerTypeCode varchar(50) =null  , 
	@DealerType_NameAr varchar(300) =null  , 
	@DealerType_NameEn varchar(300) =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Dealer_Code varchar(50) =null  , 
	@Dealer_NameAr varchar(300) =null  , 
	@Dealer_NameEn varchar(300) =null  , 
	@BillDetail_ID uniqueidentifier =null  , 
	@Product_ID uniqueidentifier =null  , 
	@Product_Code varchar(50) =null  , 
	@Product_NameAr varchar(300) =null  , 
	@Product_NameEn varchar(300) =null  , 
	@Quantity float =null  , 
	@Price float =null  , 
	@MeasureUnit_ID uniqueidentifier =null  , 
	@MeasureUnit_Code varchar(50) =null  , 
	@MeasureUnit_NameAr varchar(300) =null  , 
	@MeasureUnit_NameEn varchar(300) =null  , 
	@Offer_ID uniqueidentifier =null  , 
	@Offer_Notes varchar(max) =null  , 
	@Store_ID uniqueidentifier =null  , 
	@Store_Code varchar(50) =null  , 
	@Store_NameAr varchar(300) =null  , 
	@Store_NameEn varchar(300) =null  , 
	@Store_Address varchar(500) =null  , 
	@IsSellPlace tinyint =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[View_BDSP]
	WHERE /*( [Bill_RowNumber] = ISNULL(@Bill_RowNumber, [Bill_RowNumber]) )
	AND ( [Bill_ID] = ISNULL(@Bill_ID, [Bill_ID]) )
	AND ( [Bill_Code] like ISNULL(@Bill_Code, [Bill_Code]) )
	AND ( [BillType_ID] = ISNULL(@BillType_ID, [BillType_ID]) )
	AND ( [BillType_Code] like ISNULL(@BillType_Code, [BillType_Code]) )
	AND ( [BillType_NameAr] like ISNULL(@BillType_NameAr, [BillType_NameAr]) )
	AND ( [BillType_NameEn] like ISNULL(@BillType_NameEn, [BillType_NameEn]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerTypeCode] like ISNULL(@DealerTypeCode, [DealerTypeCode]) )
	AND ( [DealerType_NameAr] like ISNULL(@DealerType_NameAr, [DealerType_NameAr]) )
	AND ( [DealerType_NameEn] like ISNULL(@DealerType_NameEn, [DealerType_NameEn]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Dealer_Code] like ISNULL(@Dealer_Code, [Dealer_Code]) )
	AND ( [Dealer_NameAr] like ISNULL(@Dealer_NameAr, [Dealer_NameAr]) )
	AND ( [Dealer_NameEn] like ISNULL(@Dealer_NameEn, [Dealer_NameEn]) )
	AND ( [BillDetail_ID] = ISNULL(@BillDetail_ID, [BillDetail_ID]) )
	AND ( [Product_ID] = ISNULL(@Product_ID, [Product_ID]) )
	AND ( [Product_Code] like ISNULL(@Product_Code, [Product_Code]) )
	AND ( [Product_NameAr] like ISNULL(@Product_NameAr, [Product_NameAr]) )
	AND ( [Product_NameEn] like ISNULL(@Product_NameEn, [Product_NameEn]) )
	AND ( [Quantity] = ISNULL(@Quantity, [Quantity]) )
	AND ( [Price] = ISNULL(@Price, [Price]) )
	AND ( [MeasureUnit_ID] = ISNULL(@MeasureUnit_ID, [MeasureUnit_ID]) )
	AND ( [MeasureUnit_Code] like ISNULL(@MeasureUnit_Code, [MeasureUnit_Code]) )
	AND ( [MeasureUnit_NameAr] like ISNULL(@MeasureUnit_NameAr, [MeasureUnit_NameAr]) )
	AND ( [MeasureUnit_NameEn] like ISNULL(@MeasureUnit_NameEn, [MeasureUnit_NameEn]) )
	AND ( [Offer_ID] = ISNULL(@Offer_ID, [Offer_ID]) )
	AND ( [Offer_Notes] like ISNULL(@Offer_Notes, [Offer_Notes]) )
	AND ( [Store_ID] = ISNULL(@Store_ID, [Store_ID]) )
	AND ( [Store_Code] like ISNULL(@Store_Code, [Store_Code]) )
	AND ( [Store_NameAr] like ISNULL(@Store_NameAr, [Store_NameAr]) )
	AND ( [Store_NameEn] like ISNULL(@Store_NameEn, [Store_NameEn]) )
	AND ( [Store_Address] like ISNULL(@Store_Address, [Store_Address]) )
	AND ( [IsSellPlace] = ISNULL(@IsSellPlace, [IsSellPlace]) )*/
END
GO
-- =============================================
